package com.execl.controller;

import com.execl.pojo.Execl;
import com.execl.service.impl.ExeclServiceImpl;
import com.execl.utils.SQLTableUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@Slf4j
@RefreshScope
public class ExeclController {

    @Autowired
    private SQLTableUtil sqlTableUtil;

    @Autowired
    private ExeclServiceImpl execlService;

    @RequestMapping(value = "/inserData", method = RequestMethod.GET)
    public void register() throws Exception {
        sqlTableUtil.insertData();
    }


    @RequestMapping(value = "/find", method = RequestMethod.GET)
    public void find() throws Exception {
        List<Execl> execlList = execlService.find();
        System.out.println(execlList.size());
    }

    @Value("${user.name}")
    private String name;


    @RequestMapping(value = "refresh", method = RequestMethod.GET)
    public String refresh(){
        return name;
    }
}
